<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('会员充值订单缩略列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="petrol-order-desc-list-form">
                <input type="hidden" name="payTimeBegin" th:value="${beginTime}">
                <input type="hidden" name="orderStatus" value="3">
                <input type="hidden" name="payTimeEnd" th:value="${endTime}">
                <div class="select-list">
                    <ul>
                        <li>
                            <p style="width: 110px">手机号： </p>
                            <input type="text" name="phone"/>
                        </li>
                        <li>
                            <p style="width: 110px">订单号： </p>
                            <input type="text" name="orderSn"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    const prefix = ctx + "back/shopOrder";
    const orderStatusDict = [[${@dict.getType('order_status')}]];
    const payStatusDict = [[${@dict.getType('pay_status')}]];
    const closeFlag = [[${@permission.hasPermi('back:shopOrder:rechargeCancel')}]];

    $(function () {
        var options = {
            url: prefix + "/searchRechargeList",
            exportUrl: prefix + "/export",
            modalName: "会员充值订单",
            sortName: "payTime",
            sortOrder: "desc",
            height: 540,
            footerStyle: footerStyle,
            showSearch: true,
            showFooter: true,
            showColumns: false,
            columns: [
                {
                    field: 'payTime',
                    title: '支付时间',
                    sortable: true,
                    footerFormatter: function (value) {
                        return "本页数据汇总：" ;
                    },
                },
                {
                    field: 'paySn',
                    title: '付款单号',
                    visible:false,
                    sortable: true
                },
                {
                    field: 'phone',
                    title: '会员信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        let imgHtml = $.common.sprintf("<img class='img-circle img-xs' data-height='%s' data-width='%s' data-target='%s'  style='border-radius: 0;' src='%s'/>", 500, 'auto', 'self', row.avatar);
                        actions.push(imgHtml);
                        actions.push('<span style="font-weight: bold">' + row.phone + '</span><br/>');
                        return actions.join('');
                    }
                },
                {
                    field: 'amount',
                    title: '充值金额',
                    sortable: true,
                    footerFormatter: function (value) {
                        var sumAmount = 0;
                        for (var i in value) {
                            sumAmount += parseFloat(value[i].amount);
                        }
                        return sumAmount.toFixed(2);
                    },
                },
                {
                    field: 'payAmount',
                    title: '实付金额',
                    sortable: true,
                    footerFormatter: function (value) {
                        var sumAmount = 0;
                        for (var i in value) {
                            sumAmount += parseFloat(value[i].payAmount);
                        }
                        return sumAmount.toFixed(2);
                    },
                },
                {
                    field: 'payStatus',
                    title: '支付信息',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<label>支付状态：</label><span style="font-weight: bold">' + $.table.selectDictLabel(payStatusDict, value) + '</span>');
                        if (parseInt(value) === 1) {
                            actions.push('<br/><label>支付时间：</label><span style="font-weight: bold">' + row.payTime + '</span>');
                        }
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

    function footerStyle(column) {
        return {
            amount: {
                css: {color: 'red', 'font-weight': 'bold'}
            },
            payAmount: {
                css: {color: 'red', 'font-weight': 'bold'}
            },
        }[column.field]
    }

</script>
</body>
</html>